package cre.tomcat7.ch03.servlet;

import javax.servlet.*;
import java.io.IOException;
import java.io.PrintWriter;

import static cre.tomcat7.ch02.Constant.SUCCESS_RESPONSE_LINE;

/**
 * @Author penglai
 * @Date 2017/1/3.
 */
public class PrimitiveServlet implements Servlet {

    public void init(ServletConfig config) throws ServletException {
        System.out.println("init method");
    }

    public ServletConfig getServletConfig() {
        return null;
    }

    public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
        System.out.println("in service method");
        PrintWriter writer = res.getWriter();
        writer.print(SUCCESS_RESPONSE_LINE);
        writer.println("this is println");
        writer.print("this is print");
    }

    public String getServletInfo() {
        return null;
    }

    public void destroy() {
        System.out.println("destroy method");
    }
}
